<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <ul>
      <li><a href="" class="link">超链接1</a></li>
      <li><a href="" class="link">超链接1</a></li>
      <li><a href="" class="link">超链接1</a></li>
      <li><a href="" class="link">超链接1</a></li>
    </ul>
    <button>点击一下</button>
    <script>
      var u1 = document.querySelector("ul");
      var link1 = document.getElementsByTagName("link");
      u1.onclick = function () {
        if (event.target.className == "link") {
          alert("我是超链接1");
        }
      };

      var btn = document.querySelector("button");
      btn.onclick = function () {
        var l1 = document.createElement("li");
        l1.innerHTML = "<a href=''>新建的超链接</a>";
        u1.appendChild(l1);
        l1.onclick = function () {
          alert("新建的超链接");
        };
      };
    </script>
  </body>
</html>
